home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / langs / dl_exsrc.zoo / getosver.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-03  |  2.8 KB  |  62 lines

  1. /* OS header-reading routine courtesy of Ken Badertscher -- 6/27/93 sb */
  2.  
  3. /*
  4. With some versions of the Atari hard disk driver, the OS header was
  5. copied into RAM by the driver so that it could find the date a system
  6. was built in order to add OS pool.  Unfortunately, the way it copied
  7. the header obliterated the `os_conf' word in the RAM OS header. The
  8. `os_conf' word tells you which country the TOS version was built for. 
  9. If you need to find out what country your program is running in, you
  10. must check the ROM copy of the OS header.  You can get the address of
  11. the ROM os header by dereferencing the pointer `os_beg' in the RAM OS
  12. header, and you can get the address of the RAM OS header from the
  13. system variable `_sysbase', located at 0x4f2.
  14.  
  15. This is the structure of the OS header (it is also described in the
  16. Hitchhiker's Guide to the BIOS, on page 55, in the section entitled
  17. "PUNTAES and the OS Header (Gory Details)"):
  18. */
  19.  
  20. #include <osbind.h>
  21.  
  22. typedef struct _os_header {  /* offset description                   */
  23.                             /* --- -------------------------------- */
  24. unsigned short  os_entry;   /* $00 BRA to reset handler             */
  25. unsigned short  os_version; /* $02 TOS version number               */
  26.     void        *reseth;    /* $04 -> reset handler                 */
  27. struct _os_header *os_beg;   /* $08 -> base of OS                    */
  28.     void        *os_end;    /* $0c -> end BIOS/GEMDOS/VDI ram usage */
  29.     void        *os_rsv1;   /* $10 << unused, reserved >>           */
  30.     void        *os_magic;  /* $14 -> GEM memory usage parm. block  */
  31.     long        os_date;    /* $18 Date of system build ($MMDDYYYY) */
  32. unsigned short  os_conf;    /* $1c OS configuration bits            */
  33. unsigned short  os_dosdate; /* $1e DOS-format date of system build  */
  34. /* The next three fields are only available in TOS versions 1.2 and greater */
  35.     void        **p_root;   /* $20 -> base of OS pool               */
  36.     char        **pkbshift; /* $24 -> keyboard shift state variable */
  37.     void        **p_run;    /* $28 -> GEMDOS PID of current process */
  38.     void        *p_rsv2;    /* $2c << unused, reserved >>           */
  39. } OSHEADER;
  40.  
  41. #define SYSBASE ((OSHEADER **)(0x4f2L))
  42.  
  43. unsigned int GetTOSvers(long *OS_date, unsigned int *OS_conf,
  44.             unsigned int * OS_dosdate)
  45. {
  46.     /* Get the RAM OS header, then use it to get at the "real"
  47.      * OS header, since the RAM one doesn't contain a valid
  48.      * os_conf word with some hard disk drivers.
  49.      */
  50.     register void *savestack = (void *)Super(0L);
  51.     register OSHEADER *os_header = *SYSBASE;
  52.     Super(savestack);
  53.     os_header = os_header->os_beg;
  54.     if (OS_date)
  55.     *OS_date = os_header->os_date;
  56.     if (OS_conf)
  57.     *OS_conf = os_header->os_conf;
  58.     if (OS_dosdate)
  59.     *OS_dosdate = os_header->os_dosdate;
  60.     return os_header->os_version;
  61. }
  62.